1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.CellLayoutIF; 26 27 private import glib.ListG; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtk.CellArea; 31 private import gtk.CellRenderer; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 35 36 /** 37 * An interface for packing cells 38 * 39 * `GtkCellLayout` is an interface to be implemented by all objects which 40 * want to provide a `GtkTreeViewColumn` like API for packing cells, 41 * setting attributes and data funcs. 42 * 43 * One of the notable features provided by implementations of 44 * `GtkCellLayout` are attributes. Attributes let you set the properties 45 * in flexible ways. They can just be set to constant values like regular 46 * properties. But they can also be mapped to a column of the underlying 47 * tree model with gtk_cell_layout_set_attributes(), which means that the value 48 * of the attribute can change from cell to cell as they are rendered by 49 * the cell renderer. Finally, it is possible to specify a function with 50 * gtk_cell_layout_set_cell_data_func() that is called to determine the 51 * value of the attribute for each cell that is rendered. 52 * 53 * # GtkCellLayouts as GtkBuildable 54 * 55 * Implementations of GtkCellLayout which also implement the GtkBuildable 56 * interface (`GtkCellView`, `GtkIconView`, `GtkComboBox`, 57 * `GtkEntryCompletion`, `GtkTreeViewColumn`) accept `GtkCellRenderer` objects 58 * as `<child>` elements in UI definitions. They support a custom `<attributes>` 59 * element for their children, which can contain multiple `<attribute>` 60 * elements. Each `<attribute>` element has a name attribute which specifies 61 * a property of the cell renderer; the content of the element is the 62 * attribute value. 63 * 64 * This is an example of a UI definition fragment specifying attributes: 65 * 66 * ```xml 67 * <object class="GtkCellView"> 68 * <child> 69 * <object class="GtkCellRendererText"/> 70 * <attributes> 71 * <attribute name="text">0</attribute> 72 * </attributes> 73 * </child> 74 * </object> 75 * ``` 76 * 77 * Furthermore for implementations of `GtkCellLayout` that use a `GtkCellArea` 78 * to lay out cells (all `GtkCellLayout`s in GTK use a `GtkCellArea`) 79 * [cell properties](class.CellArea.html#cell-properties) can also be defined 80 * in the format by specifying the custom `<cell-packing>` attribute which can 81 * contain multiple `<property>` elements. 82 * 83 * Here is a UI definition fragment specifying cell properties: 84 * 85 * ```xml 86 * <object class="GtkTreeViewColumn"> 87 * <child> 88 * <object class="GtkCellRendererText"/> 89 * <cell-packing> 90 * <property name="align">True</property> 91 * <property name="expand">False</property> 92 * </cell-packing> 93 * </child> 94 * </object> 95 * ``` 96 * 97 * # Subclassing GtkCellLayout implementations 98 * 99 * When subclassing a widget that implements `GtkCellLayout` like 100 * `GtkIconView` or `GtkComboBox`, there are some considerations related 101 * to the fact that these widgets internally use a `GtkCellArea`. 102 * The cell area is exposed as a construct-only property by these 103 * widgets. This means that it is possible to e.g. do 104 * 105 * ```c 106 * GtkWIdget *combo = 107 * g_object_new (GTK_TYPE_COMBO_BOX, "cell-area", my_cell_area, NULL); 108 * ``` 109 * 110 * to use a custom cell area with a combo box. But construct properties 111 * are only initialized after instance `init()` 112 * functions have run, which means that using functions which rely on 113 * the existence of the cell area in your subclass `init()` function will 114 * cause the default cell area to be instantiated. In this case, a provided 115 * construct property value will be ignored (with a warning, to alert 116 * you to the problem). 117 * 118 * ```c 119 * static void 120 * my_combo_box_init (MyComboBox *b) 121 * { 122 * GtkCellRenderer *cell; 123 * 124 * cell = gtk_cell_renderer_pixbuf_new (); 125 * 126 * // The following call causes the default cell area for combo boxes, 127 * // a GtkCellAreaBox, to be instantiated 128 * gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (b), cell, FALSE); 129 * ... 130 * } 131 * 132 * GtkWidget * 133 * my_combo_box_new (GtkCellArea *area) 134 * { 135 * // This call is going to cause a warning about area being ignored 136 * return g_object_new (MY_TYPE_COMBO_BOX, "cell-area", area, NULL); 137 * } 138 * ``` 139 * 140 * If supporting alternative cell areas with your derived widget is 141 * not important, then this does not have to concern you. If you want 142 * to support alternative cell areas, you can do so by moving the 143 * problematic calls out of `init()` and into a `constructor()` 144 * for your class. 145 */ 146 public interface CellLayoutIF{ 147 /** Get the main Gtk struct */ 148 public GtkCellLayout* getCellLayoutStruct(bool transferOwnership = false); 149 150 /** the main Gtk struct as a void* */ 151 protected void* getStruct(); 152 153 154 /** */ 155 public static GType getType() 156 { 157 return gtk_cell_layout_get_type(); 158 } 159 160 /** 161 * Adds an attribute mapping to the list in @cell_layout. 162 * 163 * The @column is the column of the model to get a value from, and the 164 * @attribute is the property on @cell to be set from that value. So for 165 * example if column 2 of the model contains strings, you could have the 166 * “text” attribute of a `GtkCellRendererText` get its values from column 2. 167 * In this context "attribute" and "property" are used interchangeably. 168 * 169 * Params: 170 * cell = a `GtkCellRenderer` 171 * attribute = a property on the renderer 172 * column = the column position on the model to get the attribute from 173 */ 174 public void addAttribute(CellRenderer cell, string attribute, int column); 175 176 /** 177 * Unsets all the mappings on all renderers on @cell_layout and 178 * removes all renderers from @cell_layout. 179 */ 180 public void clear(); 181 182 /** 183 * Clears all existing attributes previously set with 184 * gtk_cell_layout_set_attributes(). 185 * 186 * Params: 187 * cell = a `GtkCellRenderer` to clear the attribute mapping on 188 */ 189 public void clearAttributes(CellRenderer cell); 190 191 /** 192 * Returns the underlying `GtkCellArea` which might be @cell_layout 193 * if called on a `GtkCellArea` or might be %NULL if no `GtkCellArea` 194 * is used by @cell_layout. 195 * 196 * Returns: the cell area used by @cell_layout 197 */ 198 public CellArea getArea(); 199 200 /** 201 * Returns the cell renderers which have been added to @cell_layout. 202 * 203 * Returns: a list of cell renderers. The list, but not the renderers has 204 * been newly allocated and should be freed with g_list_free() 205 * when no longer needed. 206 */ 207 public ListG getCells(); 208 209 /** 210 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the 211 * @cell is allocated no more space than it needs. Any unused space is 212 * divided evenly between cells for which @expand is %TRUE. 213 * 214 * Note that reusing the same cell renderer is not supported. 215 * 216 * Params: 217 * cell = a `GtkCellRenderer` 218 * expand = %TRUE if @cell is to be given extra space allocated to @cell_layout 219 */ 220 public void packEnd(CellRenderer cell, bool expand); 221 222 /** 223 * Packs the @cell into the beginning of @cell_layout. If @expand is %FALSE, 224 * then the @cell is allocated no more space than it needs. Any unused space 225 * is divided evenly between cells for which @expand is %TRUE. 226 * 227 * Note that reusing the same cell renderer is not supported. 228 * 229 * Params: 230 * cell = a `GtkCellRenderer` 231 * expand = %TRUE if @cell is to be given extra space allocated to @cell_layout 232 */ 233 public void packStart(CellRenderer cell, bool expand); 234 235 /** 236 * Re-inserts @cell at @position. 237 * 238 * Note that @cell has already to be packed into @cell_layout 239 * for this to function properly. 240 * 241 * Params: 242 * cell = a `GtkCellRenderer` to reorder 243 * position = new position to insert @cell at 244 */ 245 public void reorder(CellRenderer cell, int position); 246 247 /** 248 * Sets the `GtkCellLayout`DataFunc to use for @cell_layout. 249 * 250 * This function is used instead of the standard attributes mapping 251 * for setting the column value, and should set the value of @cell_layout’s 252 * cell renderer(s) as appropriate. 253 * 254 * @func may be %NULL to remove a previously set function. 255 * 256 * Params: 257 * cell = a `GtkCellRenderer` 258 * func = the `GtkCellLayout`DataFunc to use 259 * funcData = user data for @func 260 * destroy = destroy notify for @func_data 261 */ 262 public void setCellDataFunc(CellRenderer cell, GtkCellLayoutDataFunc func, void* funcData, GDestroyNotify destroy); 263 }